<?php
require_once("conf/db_connection.php");

$query_archive="SELECT * FROM trip_detail WHERE status='complete'";
$result_archive=mysql_query($query_archive);
?>
<html>
<head>
<script type="text/javascript" src="lib/js/main.js"></script>
<script type='text/javascript'>
function popIncident(id)
{
	xmlhttp_incident=GetXmlHttpObject();
	if (xmlhttp_incident==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url="ajax_pop_incident.php";
	url=url+"?id="+id;
	xmlhttp_incident.onreadystatechange=function (){
	  if (xmlhttp_incident.readyState==4)
	  {
		parent.disableDiv();
		parent.document.getElementById("pop_div").innerHTML = xmlhttp_incident.responseText;
		parent.showPopDiv();
		//$("#myid", top.document); 
		parent.txtToDatePicker();
	  }
	}
	xmlhttp_incident.open("GET",url,true);
	xmlhttp_incident.send(null);	
}

function popStatusLog(cell,truck)
{
	xmlhttp_incident=GetXmlHttpObject();
	if (xmlhttp_incident==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url="ajax_pop_status_log.php";
	url=url+"?cell="+cell;
	url=url+"&truck="+truck;
	xmlhttp_incident.onreadystatechange=function (){
	  if (xmlhttp_incident.readyState==4)
	  {
		parent.disableDiv();
		parent.document.getElementById("pop_div").innerHTML = xmlhttp_incident.responseText;
		parent.showPopDiv();
		//$("#myid", top.document); 
		parent.txtToDatePicker();
	  }
	}
	xmlhttp_incident.open("GET",url,true);
	xmlhttp_incident.send(null);	
}
</script>
<style type = "text/css">
#hor-minimalist-b {
	background-color: #FFFFFF;
    border-collapse: collapse;
    font-family: Georgia;
    font-size: 12px;
    margin: 10px;
    text-align: left;
    width: 900px;
}
#hor-minimalist-b th {
    border-bottom: 2px solid #5F0C0C ;
    color: #5F0C0C;
    font-size: 12px;
    font-weight: bold;
    padding: 10px 8px;
}
#hor-minimalist-b td {
    border-bottom: 1px solid #888888;
    color: #000000;
    padding: 6px 8px;
}
#hor-minimalist-b tbody tr:hover td {
    //color: #0000CC;
	background-color:#BCC5C6;
}
</style>
</head>
<body>
<table border='1' width='900' style='background-color:white;margin-left:auto;margin-right:auto;background-color:#5F0C0C;color:white;font-family:Georgia;font-size:12px'>
<th>COMPLETED TRIPS</th>
</table>
<table id='hor-minimalist-b' border='0' width='900' style='margin-left:auto;margin-right:auto'>
<thead>
<tr>
	<!--<th>Status</th>-->
	<th>Booking Number</th>
	<th>Equipment Size</th>
	<th>Equipment Type</th>
	<th>Positioning Date</th>
	<th>Positioning Time</th>
	<th>Date/Time Received </th>
	<th>Tools</th>
</tr>
</thead>
<?php
while($row_archive = mysql_fetch_array($result_archive))
{
$query_plate = "SELECT plate,contact_cellphone FROM truck WHERE id='".$row_archive["truck_id"]."'";
$result_plate = mysql_query($query_plate) or die("SELECT PLATE ".mysql_error());
$row_plate = mysql_fetch_array($result_plate);

$tas_id = $row_archive['id'];
$cell = substr(trim($row_plate['contact_cellphone']),-10);
$truck_id = $row_archive["truck_id"];
?>
<tbody>
<tr>
	<!--<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo strtoupper($row_archive["status"]) ?>&nbsp;</td>-->
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_archive["booking_number"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_archive["equipment_size"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_archive["equipment_type"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_archive["positioning_date"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_archive["positioning_time"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_archive["receive_date_time"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<img onClick=popStatusLog(<?php echo $cell?>,<?php echo $truck_id?>); style='width:25px;height:25px;cursor:pointer;' src='image/status_log.png' title='Message List' />
	&nbsp;<img onClick=popIncident(<?php echo $tas_id ?>); style='width:25px;height:25px;cursor:pointer;' src='image/incident.png' title='Incident List' /></td>
</tr>
</tbody>
<?php
}
?>
</table>		
</body>
</html>

